package tests;

import common.Utils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

public class NoLoginPage{
    public static String loginUrl = "http://127.0.0.1:58080/sign-in.html";
    public static String listUrl = "http://127.0.0.1:58080/index.html";
    public static WebDriver driver = Utils.createWebdriver();


    /**
     * loginFailByNull
     * 用户名或者密码为空
     */
    public static void loginFailByNull() {
        driver.get(loginUrl);
        driver.findElement(By.cssSelector("#submit")).click();
        driver.findElement(By.cssSelector("#signInForm > div.mb-3 > div"));
        driver.navigate().refresh();
    }

    /**
     * loginFailByUsername
     * 用户名或者密码错误
     */
    public static void loginFailByUsername() {
        driver.get(loginUrl);
        driver.findElement(By.cssSelector("#username")).sendKeys("56451648");
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#submit")).click();
        driver.findElement(By.cssSelector("body > div.jq-toast-wrap.bottom-right > div"));
        driver.navigate().refresh();
    }

    public static void listPageNoLogin() {
        driver.get(listUrl);
        driver.findElement(By.cssSelector("body > div > div > div > div:nth-child(1) > div > div.card.card-md > div > h2"));
    }
}
